<html>
<head><meta charset="utf-8"><title>FunctionId from ExprId · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/FunctionId.20from.20ExprId.html">FunctionId from ExprId</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="198544577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/FunctionId%20from%20ExprId/near/198544577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/FunctionId.20from.20ExprId.html#198544577">(May 23 2020 at 17:34)</a>:</h4>
<p>Hi, I'm trying to tackle <a href="https://github.com/rust-analyzer/rust-analyzer/issues/190">https://github.com/rust-analyzer/rust-analyzer/issues/190</a> . (track unsafe calls within exprs) I've already modified <code>FunctionData</code> to keep track of whether it's unsafe or not. I'm stuck at trying to get a <code>FunctionId</code> given that I've narrowed down my <code>Expr</code> to the <code>Expr::Call</code> variant.</p>



<a name="198545165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/FunctionId%20from%20ExprId/near/198545165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/FunctionId.20from.20ExprId.html#198545165">(May 23 2020 at 17:51)</a>:</h4>
<p>Just figured it out (using infer)</p>



<a name="198548483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/FunctionId%20from%20ExprId/near/198548483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/FunctionId.20from.20ExprId.html#198548483">(May 23 2020 at 19:29)</a>:</h4>
<p>So I think I have part 2 of <a href="https://github.com/rust-analyzer/rust-analyzer/issues/190#issuecomment-565817234">https://github.com/rust-analyzer/rust-analyzer/issues/190#issuecomment-565817234</a> figured out, but I'm not sure how to approach part 1 or how to connect the two. I also think I've hacked in the diagnostics for part two so that it can be called from <a href="https://github.com/rust-analyzer/rust-analyzer/blob/f4f5fca10175b8d5fdfa36563c103f81b2b0acd3/crates/ra_hir/src/code_model.rs#L640">https://github.com/rust-analyzer/rust-analyzer/blob/f4f5fca10175b8d5fdfa36563c103f81b2b0acd3/crates/ra_hir/src/code_model.rs#L640</a>. Does anyone have a recommended way of approaching part 1, or would someone have time between now and Monday night to go over the best way to organize some of this code?</p>



<a name="198556373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/FunctionId%20from%20ExprId/near/198556373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/FunctionId.20from.20ExprId.html#198556373">(May 23 2020 at 23:16)</a>:</h4>
<p>Have a PR up but I forgot to account for actual unsafe ops. I only tracked calls to unsafe fns</p>



<a name="198568845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/FunctionId%20from%20ExprId/near/198568845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/FunctionId.20from.20ExprId.html#198568845">(May 24 2020 at 06:13)</a>:</h4>
<p>Got pretty far with this today. Stuck at this section at the moment: <a href="https://github.com/rust-analyzer/rust-analyzer/pull/4587/files#r429603035">https://github.com/rust-analyzer/rust-analyzer/pull/4587/files#r429603035</a> Not really sure how to go from <code>Expr::Call</code> or <code>Expr::MethodCall</code> to <code>FunctionData</code>. Overall PR is here: <a href="https://github.com/rust-analyzer/rust-analyzer/pull/4587">https://github.com/rust-analyzer/rust-analyzer/pull/4587</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>